package com.adopapa.wechatapi;

import com.adopapa.wechatapi.application.service.EWechatApi;
import com.adopapa.wechatapi.domain.message.Article;
import com.adopapa.wechatapi.enterprise.domain.Member.Attr;
import com.adopapa.wechatapi.enterprise.domain.activeMessage.EMpNewsCustomerMessage.MpNews;
import com.adopapa.wechatapi.enterprise.domain.activeMessage.ENewsCustomerMessage;
import com.adopapa.wechatapi.enterprise.domain.activeMessage.ENewsCustomerMessage.News;

public class MessageMain {
	
	public static void main(String[] args) throws Exception {
		String token = "SbrxPkg5Njc6vZgQaSDgyDZ6Xe8kifOufcJ3DsKGKPVWRz2zdhKm3YhPWjv7YSA9";
		
//		String mediaId = (String) MemCachedManager.getInstance().getValue("help.index");
//		if (Tools.empty(mediaId)) {
//			String fileName = "/home/adopapa/workspace/002/steelwalkworld/mobile/WebContent/resources/images/helpIndex.jpg";
//			File file = new File(fileName);
//			UploadMediaResult result = EWechatApi.uploadTempMedia(token, file, MediaType.image.name());
//			mediaId = result.getMediaId();
//			if (!Tools.empty(mediaId)) {
//				MemCachedManager.getInstance().setValue("help.index", result.getMediaId(), (3 * 24 * 60 * 60 - 5 * 60));
//			}
//		}
		
//		String  mediaId = "1E4bbtm606rfRStMI6YL9XZ83cR3AwlJM_AwcOx0BaXe1UurPai2YeVbLaOUSe7YWfkrArgXofPyB8iRRdFPzCg";
//		System.out.println(mediaId);
		
		ENewsCustomerMessage customerMessage = new ENewsCustomerMessage();
		News news = new News();
		Article article = new Article();
		article.setTitle("欢迎了解“一点钢”，来看看功能介绍和操作攻略吧！");
		article.setDescription("一点钢网将为你提供： ▲ 免费帮你卖货；▲ 线上锁货，线下交易全程伴随式安全采购；▲ 为你创建互联网营销渠道；▲ 分享式众筹互助基金");
		article.setPicUrl("http://admin.yidiangang.com/resources/images/helpIndex.jpg");
		article.setUrl("https://qy.weixin.qq.com/cgi-bin/wap_getnewsmsg?action=get&__biz=MzI0OTQ4NjAxMQ==&mixuin=MjMwMjE0OTUxMDE2Mzg2OTA5NA==&mid=10000057&idx=1&sn=defd54f38f0849eaff6dcf361824ca61");
		news.getArticles().add(article);
		customerMessage.setNews(news);
		customerMessage.setAgentId(0);
		customerMessage.setToUser("F001|F002");
	
		
		System.out.println(customerMessage);
		boolean sendMessage = EWechatApi.sendMessage(token, customerMessage);
		
		System.out.println(sendMessage);
	}
}
